<?php

namespace App\Http\Requests\App;

use App\Http\Requests\ApiRequest;
use Illuminate\Validation\Rule;

/**
 * @property string $wechat_user_id
 * @property string $name
 * @property string $phone
 * @property string $ali_account
 * @property string $staff
 */
class StaffUpdateRequest extends ApiRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'wechat_user_id' => 'sometimes|required|int',
            'name'           => 'sometimes|required|string|max:'.self::MAX_STRING,
            'phone'          => 'sometimes|required|regex:/^1[34578][0-9]{9}$/|string',
            'ali_account'    => ['sometimes', 'string', 'max:'.self::MAX_STRING],
        ];
    }

    public function attributes()
    {
        return [
            'name' => trans('validation.panx_attr.app.staff.name'),
            'phone' => trans('validation.panx_attr.app.staff.phone'),
        ];
    }
}
